import axios from '../AxiosConfig.js'

export const selectConnection = (name) => {
  return axios({
    method: 'get',
    url: '/api/connections/' + encodeURIComponent(name)
  })
}

export const selectConnectionByUsername = (username) => {
  return axios({
    method: 'get',
    url: '/api/connections/username/' + username,
  })
}

export const listConnection = () => {
  return axios({
    method: 'get',
    url: '/api/connections',
    params: {
      "page": 1,
      "page_size": 500,
      "name": "",
      "use_regex": false
    }
  })
}

export const listConnectionChannel = (name) => {
  return axios({
    method: 'get',
    url: '/api/connections' + encodeURIComponent(name) + '/channels'
  })
}

export const closeConnection = (name) => {
  return axios({
    method: 'delete',
    url: '/api/connections/' + encodeURIComponent(name)
  })
}

export const closeConnectionByUsername = (username) => {
  return axios({
    method: 'delete',
    url: '/api/connections/username/' + username,
  })
}


